package com.wryyyyy.service.impl;

import com.wryyyyy.dto.Result;
import com.wryyyyy.dto.UploadData;
import com.wryyyyy.service.IApproachService;
import com.wryyyyy.utils.ExcelService;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import static com.wryyyyy.utils.SystemConstants.ARGS_LENGTH;

@Service
public class ApproachServiceImpl implements IApproachService {

    @Resource
    private ExcelService excelService;

    @Resource
    private CallService callService;

    @Override
    public Result upload(String filePath) {
        excelService.readExcelFile(filePath);
//        return Result.ok(new UploadData(excelService.getArguments(), excelService.getTableHead()));
        return Result.ok(new UploadData(excelService.getRow()-1, excelService.getCol()-1, excelService.getArguments(), excelService.getTableHead()));
    }

    @Override
    public Result deal(String[] args, Integer method) {
        return Result.ok(callService.executeCppProgram(method, args));
    }
}